package org.enwey.icarenew.Activity.Login;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import org.enwey.icarenew.APPUtils.ToastUtil;
import org.enwey.icarenew.APPUtils.Validator;
import org.enwey.icarenew.Activity.Base.BaseActivity;
import org.enwey.icarenew.R;

/**
 * Created by enwey on 2014/11/23.
 */
public class ResetPhoneNumber extends BaseActivity {
    private EditText mPhoneNum;
    private TextView mNext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reset_phone);
        setUp();
        findView();
        registerListener();
    }

    private void setUp() {
        showLeftBtn();
        setTitle("重设密码");
    }

    private void findView() {
        mPhoneNum = (EditText) this.findViewById(R.id.activity_reset_phone_phone);
        mNext = (TextView) this.findViewById(R.id.activity_reset_phone_btn);
    }

    private void registerListener() {
        View.OnClickListener register = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                doNext();
            }
        };
        mNext.setOnClickListener(register);
    }

    private void doNext() {
        String phoneNum = mPhoneNum.getText().toString().trim();

        if (TextUtils.isEmpty(phoneNum)) {
            ToastUtil.show(ResetPhoneNumber.this, "手机号码不能为空!");
            return;
        }
        if (!Validator.isPhone(phoneNum)) {
            ToastUtil.show(ResetPhoneNumber.this, "请输入正确手机号码！");
            return;
        }

        Intent intent = new Intent(ResetPhoneNumber.this, ResetSetPassword.class);
        intent.putExtra("phone", phoneNum);
        startActivity(intent);

    }

}
